<?php

/**
 * Error Message Class to handle alll message types and codes
 * SGN_ECD = Error Code Definition
 *
 * @package SGN_Core
 * @version $Id: Application.php 1424 2012-03-03 08:15:52Z locth $
 * @author $Author: locth $
 *
 */
class SGN_ECD
{
    // most common const
    const SUCCESS = 1;
    const EXCEPTION = -2;
    const ERR_NOT_AJAX = -3;
    const UNKNOWN_ERROR = 0;
    const ACCOUNT_NOT_FOUND = 1001;
    const COMMENT_ITSNOTYOURCHAR = -5;
    const COMMENT_NEWCOMMENT_DISABLED = -4;
    const COMMENT_TIMEBETWEENPOST_ERROR = -3;
    const NOT_EXIST = 2003;
    const PROFILE_UPLOADPICTURE_CREATEDIR_ERROR = 3001;
    const PROFILE_USER_NOT_EXIST = 3002;
    const PROFILE_INVALID_INPUT = 3003;
    const NOT_LOG_IN = 3004;
    const INVALID_TOKEN = 3005;
    const INVALID_ACHIEVEMENT_TYPE = 3006;
    const PROFILE_ACCOUNT_ALREADY_EXIST = 3007;
    const PROFILE_CANNOT_CREATE_ID = 3008;
    const PROFILE_CANNOT_CREATE_TRANSPORT_OBJECT = 3009;
    const PROFILE_CANNOT_TRANSPORT_USERID = 3010;
    const NOT_ALLOWED_ACTION = 3011;
    const CANNOT_GET_ACCOUNTNAME = 3012;
    const INSERT_DB_FAIL = 3013;
    const MEMCACHE_QUEUE_SEND_FAIL = 3014;
    const CANNOT_INDEX_USER = 3015;
    const CANNOT_SAVE_CACHE = 3016;
    const SEND_NOTIF_ERROR = 3017;
    const INVALID_PRODUCT_CODE = 3018;
    const ACCESS_TOKEN_NOT_MATCH_APPNAME_AND_USERID = 3019;
    const ZINGME_ID_NOT_FOUND = 3020;
    const USER_IS_NOT_LOGIN = 3021;
    const PHONE_NO_NOT_EXIST = 3022;
    const PHONE_NO_NOT_VERIFIED = 3023;
    const PHONE_NO_NOT_VALID = 3024;
    const SEND_SMS_FAILED = 3025;
    const SMS_MESSAGE_TOO_LONG = 3026;
    const INVALID_BITNO = 3027;
    
    const API_MISSING_PARAM = 5001;
    const API_APP_INVALID = 5003;
    const API_SECRETKEY_INVALID = 5004;
    const API_APIKEY_INVALID = 5005;
    const API_ENDPOINT_MISSING = 5006;
    const API_CANNOT_GENERATE_AUTHCODE = 5007;
    const API_UNSUPPORTED_ID_TYPE = 5008;
    const API_PARAM_INVALID = 5007;
    const API_LEADER_BOARD_CODE_INVALID = 5009;
    const API_USERID_INVALID = 5010;

    const API_NOT_FOUND_USER = 6001;
    const API_NOT_FOUND_FRIENDS = 6002;
    const API_NOT_FOUND_GAMES = 6003;
    const API_NOT_FOUND_DATA = 6004;
    const API_USER_SUCCESS = 0;
    const API_CALL_FAIL = 6005;
    
    const MISSING_GAMEID = 7001;
    const MISSING_SERVERID = 7002;
    const MISSING_GUILDID = 7003;
    const MISSING_USERNAME = 7004;
    const WRONG_USERNAME = 7005;
    const MEMBER_IS_NOT_FRIEND = 7006;
    const DONT_HAVE_PERMISSION = 7007;
    const GUILD_EXIST = 7008;
    
    
    const WRONG_TITLE_EVENT = 8001;
    
    const CANNOT_GET_ROLE_INFO = 3100;
    
    /**
     * Get error message of a value. It's actually the constant's name
     * @param integer $value
     * 
     * @return string
     */
    public static function getErrorMessage($value)
    {
        $class = new ReflectionClass('SGN_ECD');
        $constants = $class->getConstants();
        $constants = array_flip($constants);
        return $constants[$value];
    }
}